<!DOCTYPE HTML>
<html>
<head>
    <title>帮教对象走访页面</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <link href="/static/css/default.css" rel="stylesheet" type="text/css" />
    <script src="/static/js/common/common.js" type="text/javascript"></script>
</head>
<style>
    .delBtn {
        border:1px solid #ff2120;
        border-radius:10px;
        font-size:8px;
        line-height:20px;
        font-weight:bold;
        color:#ff4634;
    }
    .editBtn {
        border:1px solid #018d00;
        border-radius:10px;
        font-size:8px;
        line-height:20px;
        font-weight:bold;
        color:#00a60a;
    }
</style>
<body>
<div class="mini-fit">
    <#--罪犯编号-->
    <input id="priNum" name="priNum" class="mini-hidden" value="${prisonerBaseInfo.priNum}" />
    <div style="height:100%;width: 100%;overflow-x: auto;overflow-y: auto;padding: 10px;">
        <div id="editform" class="form" style="padding:10px;">
            <span style="font-size: 15px">${prisonerBaseInfo.pname!''}&emsp;</span>/<span style="font-size: 15px">${prisonerBaseInfo.sex!''}</span>
        </div>
        <div id="editform2" class="form" style="padding:10px;">
            <table class="form-table" width="100%">
                <tr style="line-height: 30px;">
                    <td width="40%"><span style="color: #8B8B8B">身份证号:&emsp;</span>${prisonerBaseInfo.idnum!''}
                    </td>
                    <td width="40%"><span style="color: #8B8B8B">出生日期:&emsp;</span>${prisonerBaseInfo.age!''}
                    </td>
                </tr>
                <tr style="line-height: 30px;">
                    <td><span style="color: #8B8B8B">户籍地址:&emsp;</span>${prisonerBaseInfo.hjdz!''}
                    </td>
                    <td><span style="color: #8B8B8B">居住地址:&emsp;</span>${prisonerBaseInfo.jzdz!''}
                    </td>
                </tr>
            </table>
        </div>
        <div id="editform3" class="form" style="padding:10px;">
            <span style="font-size: 18px">走访信息&emsp;&emsp;&emsp;</span> <a class="mini-button mini-button-primary"
                                                                           onclick="addAzInfoData('${prisonerBaseInfo.priNum!''}')">新增</a>
        </div>
        <div>
            <div>
                <div id="datagrid1" class="mini-datagrid" style="width: 100%;" ajaxType="get" alwaysShowEmptyText="true"
                     autoload="true" showEmptyText="true" emptyText="暂无数据" multiSelect="true" showPager="false"
                     url="/azbj/azbjgl/bjgzgl/view/getZfInfoList?priNum=${prisonerBaseInfo.priNum!''}">
                    <div property="columns">
                        <div type="indexcolumn" align="center" width="10%" headerAlign="center" width="20%">序号</div>
                        <div name="zoufangTime" field="zoufangTime" width="20%" align="center" headerAlign="center" allowSort="false">走访时间
                        </div>
                        <div name="zoufangDanwei" field="zoufangDanwei" width="40%" align="center" headerAlign="center" allowSort="false">走访单位
                        </div>
                        <div name="action" width="30%" align="center" headerAlign="center" renderer="onActionRenderer" allowSort="false">操作
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    mini.parse();
    var ftab = 1;
    var priNumObj = mini.get("priNum");
    var grid = mini.get("datagrid1");

    function refreshPage(action) {
        if (action == "close") {
            window.location.reload();
        }
    }

    //渲染列中按钮
    function onActionRenderer(e) {
        var s = '';
        s += '&nbsp;<a class="mini-button mini-button-primary"  onclick="editZfInfoData()"  >&nbsp;&nbsp;编辑&nbsp;&nbsp;</a>&nbsp';
        s += '&nbsp;<a class="mini-button mini-button-danger"   onclick="delZfInfoData()"   >&nbsp;&nbsp;删除&nbsp;&nbsp;</a>&nbsp';
        s += '&nbsp;<a class="mini-button mini-button-info"   onclick="viewZfInfoData()"   >&nbsp;&nbsp;查看&nbsp;&nbsp;</a>&nbsp';
        return s;
    }

    function editZfInfoData(e) {
        var row = grid.getSelected();
        var priNum = priNumObj.getValue();
        mini.open({
            url: "/azbj/azbjgl/bjdxzf/view/toAddZfInfoTab?zfId=" + row.zfId + "&priNum=" + priNum,
            title: "编辑-走访信息",
            width: "900px",
            height: "80%",
            allowDrag: true,
            allowResize: false,
            showCloseButton: true,
            onload: function () {
            },
            ondestroy: function (action) {
                grid.reload();
            }
        });
    }

    function delZfInfoData(e) {
        var row = grid.getSelected();
        mini.confirm("确定要删除吗？",
            "确定？",
            function (action) {
                if (action == "ok") {
                    $.ajax({
                        url: "/azbj/azbjgl/bjdxzf/view/delZfInfoAction",
                        type: "post",
                        data: {zfId: row.zfId},
                        success: function (result) {
                            if (result.code == 1) {
                                if (action == "ok") {
                                    refreshPage("close");
                                }
                            } else {
                                mini.alert("删除失败");
                            }
                        }
                    });
                }
            });
    }

    //添加走访信息
    function addAzInfoData() {
        var priNum = priNumObj.getValue();
        mini.open({
            targetWindow: window.parent,
            url: "/azbj/azbjgl/bjdxzf/view/toAddZfInfoTab?priNum=" + priNum,
            title: "新增-走访信息",
            width: "900px",
            height: "80%",
            allowDrag: true,
            allowResize: false,
            showCloseButton: true,
            onload: function () {
            },
            ondestroy: function (action) {
                if (action == 'close'){
                    var iframe = this.getIFrameEl();
                    //获取选中、编辑的结果
                    var data = iframe.contentWindow.GetData();
                    var taskId = data.taskId;
                    var priNum = data.priNum;
                    var id = data.id;
                    $.ajax({
                        url: "/upload/downloadAppendixFile/deleteById?1=1&id=" + id + "&priNum=" + priNum + "&taskId=" + taskId,
                        type: "get",
                        success: function(success){
                        }
                    })
                }
                window.location.reload();
            }
        });
    }

    // 查看页面
    function viewZfInfoData() {
        var priNum = priNumObj.getValue();
        var row = grid.getSelected();
        mini.open({
            url: "/azbj/azbjgl/bjgzgl/view/toViewZfInfoTab?zfId="+row.zfId + "&priNum=" + priNum,
            title: "查看-走访信息",
            width: "900px",
            height: "80%",
            allowDrag: true,
            allowResize: false,
            showCloseButton: true,
            onload: function () {
            },
            ondestroy: function (action) {
                grid.reload();
            }
        });
    }
</script>
</body>
</html>